package com.nf.health.app.intervention_details.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.adapter.ViewHolder;
import com.nf.health.app.intervention_details.bean.MusicBean;
import com.nf.health.app.intervention_details.bean.PrescriptionBean;
import com.nf.health.app.utils.DateUtil;
import com.nf.health.app.utils.DensityUtil;
import com.nf.health.app.utils.ImageUtils;

import java.util.Date;
import java.util.List;

/**
 * Created by 恩福 on 2016/11/10.
 * 历史方案Adapter
 */

public class MusicAdapter extends BaseAdapter {

    List<MusicBean> list;
    Activity activity;
    LayoutInflater inflater = null;
    public MusicAdapter(Activity activity, List<MusicBean> newsList) {
        this.activity = activity;
        this.list = newsList;
        inflater = LayoutInflater.from(activity);
    }
    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        if (list != null && list.size() != 0) {
            return list.get(position);
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MusicBean item = list.get(position);
        ViewHolder holder = ViewHolder.get(parent, convertView, R.layout.item_layout_music, position);
        TextView week_text = holder.getView(R.id.week_text);
        LinearLayout bg = holder.getView(R.id.bg_lin);
        String zhou = DateUtil.date2yyyyMMddWeek2(DateUtil.dateToString(new Date(Long.parseLong(item.getMonitortime())), "yyyy-MM-dd HH:mm:ss"));
        week_text.setText(zhou);
        if(item.isClick()){
            bg.setBackgroundColor(activity.getResources().getColor(R.color.theme_color));
        }else{
            bg.setBackgroundColor(activity.getResources().getColor(R.color.white));
        }
        return holder.getConvertView();
    }

}
